Ext.onReady(function(){
	
	var username = new Ext.form.TextField({
			width : 170,
			height : 40,
			id : 'U_NAME',
			name : 'U_NAME',
			minLength : 4,
			maxLength : 50,
			allowBlank : false,
			blankText : '用户名不能为空',
			fieldLabel : '用户名',
			renderTo : 'username'
	});
		
	var password = new Ext.form.TextField({
		width : 170,
		height : 40,
		id : 'U_PASSWORD',
		name : 'U_PASSWORD',
		minLength : 4,
		maxLength : 50,
		allowBlank : false,
		blankText : '用户名不能为空',
		fieldLabel : '密码',
		inputType : 'password',
		renderTo : 'password'
	});
	
	Ext.get('loginBtn').on('click',function(){
		if(!Ext.getCmp('U_NAME').isValid()){
			ExtJ.showMessage("您输入的帐号格式不正确!");
			return;
		}
		if(!Ext.getCmp('U_PASSWORD').isValid()){
			ExtJ.showMessage("您输入的密码格式不正确!");
			return;
		}
		var username = Ext.getCmp('U_NAME').getValue();
		var password = Ext.getCmp('U_PASSWORD').getValue();
		Ext.Ajax.request({
			url : ExtJ.getActionPath("user/login.do"),
			params : {
				username : username,
				password : password
			},
			success : function(response, options) {
				var text = Ext.decode(response.responseText);
				if(text.success){
					window.location.href = baseUrl+"/pages/main/main.jsp";
				}else{
					ExtJ.showError("密码错误!");
				}
			},
			failure : function(){
				ExtJ.showError("密码错误!");
			}
		});
	});
	
	
})